//
//  NSString+URL.m
//  YanXiuWang
//
//  Created by 慧趣小歪 on 17/1/7.
//  Copyright © 2017年 小分队. All rights reserved.
//

#import "NSString+URL.h"
#import "NSString+Trim.h"

@implementation NSString (URL)

- (BOOL)isURL {
    NSString *text = self.trim;
    return [text hasPrefix:@"http://"] || [text hasPrefix:@"https://"];
}

- (NSString *)URLDecode {
    return [self stringByRemovingPercentEncoding];
}

- (NSString *)URLEncode {
    return [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:
                                                                     @"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#._-=?&/"]];
}

- (NSString *)URLEncodeParams {
    return [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:
                                                                     @"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#._-"]];
}

@end
